package com.hub.videobrowsdownload;

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class BrowsHash256 {
    public static MessageDigest a;

    public static String toHash(String s) {
        MessageDigest messageDigest0 = BrowsHash256.a;
        if(messageDigest0 == null) {
            try {
                BrowsHash256.a = MessageDigest.getInstance("SHA-256");
            }
            catch(NoSuchAlgorithmException noSuchAlgorithmException0) {
                noSuchAlgorithmException0.printStackTrace();
            }
        }
        else {
            messageDigest0.reset();
        }

        BrowsHash256.a.update(s.getBytes(StandardCharsets.UTF_8));
        byte[] arr_b = BrowsHash256.a.digest();
        StringBuilder stringBuilder0 = new StringBuilder();
        for(int v = 0; v < arr_b.length; ++v) {
            String s1 = Integer.toHexString(arr_b[v] & 0xFF);
            if(s1.length() == 1) {
                stringBuilder0.append('0');
            }

            stringBuilder0.append(s1);
        }

        return stringBuilder0.toString();
    }
}
